#include "realnumbertest.h"

bool RealNumberTest::constructorTest() {
    RealNumber *realNumb = new RealNumber();
    assert(realNumb->getValue()==0);
    delete realNumb;
    return true;
}

bool RealNumberTest::run() {
    short count=0;

    if (!RealNumberTest::constructorTest())
        std::cout << "ERROR " << ++count << " RealNumberTest.constructorTest() faild!" << std::endl;
    if (!RealNumberTest::constructorWithValueTest())
        std::cout << "ERROR " << ++count << " RealNumberTest.constructorWithValueTest() faild!" << std::endl;
    if (!RealNumberTest::compareOperatorTest())
        std::cout << "ERROR " << ++count << " RealNumberTest.compareOperatorTest() faild!" << std::endl;

    return count==0;
}

bool RealNumberTest::constructorWithValueTest() {
    RealNumber *realNumb = new RealNumber(88.472);
    assert(realNumb->getValue()==88.472);
    delete realNumb;

    RealNumber *realNumb2 = new RealNumber(-948.472);
    assert(realNumb2->getValue()==-948.472);
    delete realNumb2;

    RealNumber *realNumb3 = new RealNumber(12.1111);
    assert(realNumb3->getValue()==12.1111);
    delete realNumb3;

    return true;
}

bool RealNumberTest::compareOperatorTest() {
    RealNumber r1(22.439);
    RealNumber r2(22.439);
    assert(r1==r2);
    RealNumber r3(-34.42);
    assert(!(r1==r3));
    assert(!(r2==r3));
    RealNumber r4(-34.42);
    assert(r3==r4);
    return r4==r4;
}
